package com.lmf.springboot;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class Controll {
    @RequestMapping("/hello")
    public ModelAndView dosome(){
        ModelAndView mv=new ModelAndView();
        mv.addObject("msg","你好，世界，hello");
        mv.setViewName("index");
        return mv;
    }
    @RequestMapping("/hello2")
    public String dosome2(Model mv){
        mv.addAttribute("msg","你好，世界，hello2");
        return "index";
    }

    /**
     * 返回值为String,形参使用ModelAndView：无效果，但不报错
     * @param mv
     * @return
     */
    @RequestMapping("/hello3")
    public String dosome3(ModelAndView mv){
        mv.addObject("msg","你好，世界，hello3");
        mv.setViewName("index");
        return "index";
    }
}
